import { configureStore } from "@reduxjs/toolkit";
import reducers from "@src/reducer";

// https://github.com/facebook/hermes/issues/1228
// https://github.com/infinitered/reactotron/issues/1398#issuecomment-1913913058
const createEnhancers = (getDefaultEnhancers: Function) => {
  if (__DEV__) {
    const reactotron = require("../../ReactotronConfig").default;
    return getDefaultEnhancers().concat(reactotron.createEnhancer());
  }
  return getDefaultEnhancers();
};

// https://redux-toolkit.js.org/api/configureStore
export default configureStore({
  // 如果想持久化数据 参考 https://github.com/infinitered/reactotron/issues/1398#issuecomment-1913913058
  reducer: reducers,
  enhancers: createEnhancers,
});
// The store now has redux-thunk added and the Redux DevTools Extension is turned on
// 现在新版本的 configureStore 已经内置了 redux-thunk
